<?php
namespace Home\Controller;
use Home\Logic\Controller\MainController;
class IndexController extends MainController {
    public function index(){
//        $this->indexPay();
        if(!IS_POST){
            $this->display();
        }else{
            var_dump($_REQUEST);
        }
    }

    public function indexPay(){
        $fee = I('post.charge');
        $this->jsApiParameters = $this->weixinObj->unifyPay('商品名称',$fee);
        $this->fee = $fee;
        $this->display('indexPay');
    }
    public function createOrder(){
        $data['order_number'] = date('YmdHis') . rand(100000, 999999);
        $data['openid'] = session('openid');
        $data['remark'] = '测试订单';
        $data['created_time'] = time();
        $data['begin_time'] = time() + 60 * 60;
        $data['end_time'] = time() + 2 * 24 * 60 * 60;
        $data['total_price'] = (float)I('post.charge')/100;
        $data['pay_status'] = 0;
        $data['hid'] = M('shop_hospital')->find()['id'];
        $data['attend_type'] = 1;//院内
        $data['truename'] = "奥巴马";//名字
        $data['mobile'] = '10086';//院内
        $data['address'] = '火星';
        $data['order_type'] = 1;//订单来源
        $userInfo = M('user')->where('openid = "%s"',session('openid'))->find();
        $data['uid'] = $userInfo['id'];
//        var_dump($userInfo);die;
        var_dump(M('order_hospital')->add($data));
    }
}